<?php

class Rule_OneOf extends Rule
{
	public $fields;
	public $error_message = 'Заполните хотя бы одно из полей';
	
	function __construct($name, $fields = array(), $error_message = '')
	{
		$this->name = $name;
		$this->fields = $fields;
		if ($error_message != '') $this->error_message = $error_message;
	}
	
	function Check($hash)
	{
		foreach($this->fields as $field)
		{
			if(isset($hash[$field]) && $hash[$field]) return true;
		}
		return false;
	}
}